<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function show() {
            let pro = new Promise(function (resolve, reject) {
                setTimeout(() => {
                    resolve('成功')
                }, 4000)
            })
            return pro;
        }

        function fn() {
            return new Promise((resolve, reject) =>{
                setTimeout(() => {
                    resolve('成功')
                }, 2000);
            })
        }

        //Promise的all ，参数为promise的数组，所有异步函数执行完才执行回调
        Promise.all([show(),fn()]).then(results=>{
            console.log(results);
        },err=>{
            console.log(err);
        })
    </script>
</body>
</html>